// 转时间日期格式
export const formatTime = (num: any) => {
    if (num === 0 || num == null) {
        return ''
    } else {
        //月//日//时//分
        let date = new Date(num)
        const month = date.getMonth() + 1
        const day = date.getDate()
        const hour = date.getHours()
        const minute = date.getMinutes()
        let dateTime = (new Date().getTime() - num) / 1000
        if (dateTime < 30) {
            return '刚刚'
        } else if (dateTime / 60 < 60) {
            return Math.round(dateTime / 60) + '分钟以前'//每分钟60秒
        } else if (dateTime / 60 / 60 < 24) {
            return Math.round(dateTime / 60 / 60) + '小时以前'
        } else if (dateTime < 172800) {
            return (dateTime / 86400).toFixed(0) + "天前"
        } else {
            return `${month}月${day}日${hour}时${minute}分`
        }
    }
}

export const filDateTime = (data: any) => {
    if (data == 0 || data == null) {
        return '无'
    } else {
        const dt = new Date(data)
        const y = dt.getFullYear()
        const m = (dt.getMonth() + 1 + '').padStart(2, '0')
        const d = (dt.getDate() + '').padStart(2, '0')
        const hh = (dt.getHours() + '').padStart(2, '0')
        const mm = (dt.getMinutes() + '').padStart(2, '0')
        const ss = (dt.getSeconds() + '').padStart(2, '0')
        //时间格式年月日、时分秒
        return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
    }
}